﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace Xunit.Sgr.Oss
{
    public class OssTestFixture : IDisposable
    {
        private readonly IHost _host;

        public OssTestFixture()
        {
            _host = new HostBuilder().ConfigureAppConfiguration((hostContext, config) =>
            {
                config.AddJsonFile(@"appsettings.json");
            })
            .ConfigureServices((hostContext, serviceCollection) =>
            {
                serviceCollection.AddLogging();
                serviceCollection.AddSgrCore();
                serviceCollection.AddS3OssService(opt =>
                {
                    opt.EndPoint = "http://127.0.0.1:9000";
                    opt.UseHttps = false;
                });
            })
            .Build();
        }

        public IServiceProvider ServiceProvider => _host.Services;

        public void Dispose()
        { _host.Dispose(); }
    }
}